package com.ctshk.sapp.system.controller;

import javax.validation.Valid;

import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.system.dto.SupplierWriteOffUserDetailDTO;
import com.ctshk.rpc.system.req.AddSupplierWriteOffUserReq;
import com.ctshk.rpc.system.req.SupplierWriteOffUserQueryListReq;
import com.ctshk.rpc.system.service.ISupplierWriteOffUserService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * <p>
 * 供应商核销员表 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-04-15
 */
@Api(tags="核销员")
@RestController
@RequestMapping("/supplier/write/off/user")
public class SupplierWriteOffUserController extends BaseController {
	
	@DubboReference
	private ISupplierWriteOffUserService supplierWriteOffUserService;
	
	
	@ApiOperation(value="新增供应商核销员", notes="新增供应商核销员")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.ADD, operTitle = "新增供应商核销员", operDesc = "新增供应商核销员")
    @PostMapping("/add")
    public Result addSupplierWriteOffUser(@RequestBody @Valid AddSupplierWriteOffUserReq req){
        return supplierWriteOffUserService.addSupplierWriteOffUser(req,getCurrentUser(getRequest()).getId());
    }
	
	@ApiOperation(value="编辑供应商核销员", notes="编辑供应商核销员")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "编辑供应商核销员", operDesc = "编辑供应商核销员")
    @PostMapping("/edit")
    public Result editSupplierWriteOffUser(@RequestBody @Valid AddSupplierWriteOffUserReq req){
        return supplierWriteOffUserService.editSupplierWriteOffUser(req,getCurrentUser(getRequest()).getId());
    }
	
	@ApiOperation(value="根据id查询供应商核销员详情", notes="根据id查询供应商核销员详情")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "根据id查询供应商核销员详情", operDesc = "根据id查询供应商核销员详情")
    @GetMapping("/info/{id}")
    public Result<SupplierWriteOffUserDetailDTO> queryDetail(@PathVariable Long id){
        return supplierWriteOffUserService.queryDetail(id);
    }
	
	@ApiOperation(value="供应商核销员列表查询", notes="供应商核销员列表查询")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "供应商核销员列表查询", operDesc = "供应商核销员列表查询")
    @PostMapping("/queryList")
    public Result<PageResponse<SupplierWriteOffUserDetailDTO>> queryList(@RequestBody SupplierWriteOffUserQueryListReq req){
        PageResponse<SupplierWriteOffUserDetailDTO> supplier = supplierWriteOffUserService.queryList(req);
        return Result.success(supplier);
    }
	@ApiOperation(value="删除核销员", notes="删除核销员")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.DELETE, operTitle = "删除核销员", operDesc = "删除核销员")
    @GetMapping("/delete/{id}")
    public Result delete(@PathVariable Long id){
        return supplierWriteOffUserService.delete(id,getCurrentUser(getRequest()).getId());
    }

}
